/**
 *
 * AtJava source-code is licensed under the LGPL.
 * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
 * When copying, adapting, or redistributing this document in keeping with the guidelines above,
 * you are required to provide proper attribution to obinary.
 * If you reproduce or distribute the document without making any substantive modifications to its content,
 * please use the following attribution line:
 *
 * Copyright 2007 Atjava.com Ltd. (http://www.atjava.com) All rights reserved.
 *
 */
package com.atjava.jcrt.core.query;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author biggie
 * @version $Revision: 1.2 $ $Date: 2008/07/11 02:25:48 $
 */
public class ConditionData {

	private List<String> list = new ArrayList<String>();
	
	public static final String CONDITION_EQUAL="=";
	public static final String CONDITION_CONTAINS="jcr:contains";
	public static final String CONDITION_GT=">";
	public static final String CONDITION_GE=">=";
	public static final String CONDITION_LT="<";
	public static final String CONDITION_LE="<=";
	
	private List<String> columnList = new ArrayList<String>();
	
	public void setCondition(String column,String values,String condition){
		if(column == null || column.length() == 0){
			return;
		}
		if(values == null || values.length() == 0){
			return;
		}
		if(condition == null || condition.length() == 0){
			return;
		}
		this.columnList.add(column);
		String con = null;
		if(condition.equals(CONDITION_CONTAINS)){
			con = "["+CONDITION_CONTAINS+"(@"+column+",'"+values+"')]";
		}else{
			con = "[@"+column+condition+"'"+values+"']";
		}
		if(con != null){
			list.add(con);
		}
	}
	public List<String> getConditions(){
		return this.list;
	}
	
	public List<String> getColumns(){
		return this.columnList;
	}
}
